<?php 
// Header
$this->set('title_for_layout', __("Chỉnh sửa danh mục sản phẩm", true));

$this->left_menu = 'menu/'.$this->params['controller'];
$params = array(
	//'root'	=>	$this->params['named']['root']
);
if (isset($this->params['plugin'])) {
	$params['plugin'] = $this->params['plugin'];
} else {
	$params['plugin'] = null;
}
if (isset($this->params['named']['root'])) {
	$params['root'] = $this->params['named']['root']; 
}

// Load CSS
echo $this->Html->css('manage_categories/add.css');
echo $this->Html->css('cake.form');

// Load Javascript
echo $this->Html->script('ckeditor/ckeditor_basic');
echo $this->Html->script('/projects/js/manage_project_categories/edit');
?>
<div class='right_content'>
<h2><?php __("Chỉnh sửa danh mục tin")?></h2>
<div class="buttons atbottom">
	<ul>
		<li><a id='add_facility_link' href="<?php echo $html->url($params + array('controller'=> $this->params['controller'], 'action'	=>	'index'))?>"><?php __("Danh sách danh mục")?></a></li>
        <li><a href="javascript:void(0)" class="save"><?php __("Cập nhật")?></a></li>
	</ul>
</div>
<?php echo $session->flash()?>

<div class='form'>
<?php 
echo $form->create('ProductCategory', array(
	'url'	=>	$params + array(
		'controller'	=>	$this->params['controller'],	
		'action'		=>	'edit'
	),
	'id'		=>	'edit_category_form',
	'enctype'	=>	'multipart/form-data'
));
echo $form->input('id');
?>
<?php 
echo $form->input('name', array(
	'label'	=>	__("Tên danh mục: <font color='red'>(*)</font>:</label>",true),
	'error'	=>	__("Tên danh mục không được để trống", true)
));

if ($configs['ManageCategory']['edit']['show_alias']) {
	echo $form->input('alias', array('label'	=>	__("Alias: ", true)));
}

if (!isset($configs['Category']['deep']) || $configs['Category']['deep'] > 1) {
	echo $form->input('parent_id', array('label'	=>	__("Danh mục cha: ", true), 'options'	=>	$tree));
}

$image = $this->data['ProductCategory']['image'];
if ($image != "") {
	$ext = strrchr($image, ".");
	$pos = strrpos($image, ".");
	$filename = substr($image,0,$pos);
	$image = $filename."_thumbnail".$ext;
}

if ($configs['Category']['image']['show']):
$options = array(
	'name'				=>	$image,
	'path'				=>	$configs['Category']['thumbnail']['uri'],
	'field_name'		=>	'image',
	'label'				=>	__('&nbsp;',true),
	'legend_title'		=>	__('Hình ảnh',true),
	'delete_image_link'	=>	$html->url($params + array('controller'=> $this->params['controller'], 'action'=>'delete_image', 'category_id'	=>	$this->data['ProductCategory']['id']))
	//'/categories/manage_news/delete_image/'.$this->data['Article']['id'])
);
echo $html->form_image($options,array());
endif;
?>
<div class="input">
<table cellpadding='0' cellspacing='0' border='0' width='100%'>
<tr>
	<td class='label' valign='top'><?php __("Mô tả: ")?></td>
	<td>
		<?php
		echo $form->input('description', array('label'	=>	false, 'div'=>false)); 
		echo $wysiwyg->render("ProductCategory.description", 'ckeditor', array('uiColor'=>'#97da7f'));
		?>
	</td>
</tr>
</table>
</div>
<?php echo $form->end();?>
</div>

<div class="buttons atbottom">
	<ul>
		<li><a id='add_facility_link' href="<?php echo $html->url($params + array('controller'=> $this->params['controller'], 'action'	=>	'index'))?>"><?php __("Danh sách danh mục")?></a></li>
        <li><a href="javascript:void(0)" class="save"><?php __("Cập nhật")?></a></li>
	</ul>
</div>